<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no,minimal-ui">
	<title>首页</title>

	<link rel="stylesheet" type="text/css" href="../addons/zh_yjm/template/mobile/css/index.css">
	<link rel="stylesheet" type="text/css" href="../addons/zh_yjm/template/mobile/css/jquery-weui.css">
	<link rel="stylesheet" type="text/css" href="../addons/zh_yjm/template/mobile/css/weui.min.css"> 


	<style type="text/css">
	iframe{
		position: fixed;
		bottom: 0;
		left: 0;
		background: #fff;
		z-index: 999;	
	}
    

	.footer a:hover{
			color: red;
		}
		.weui-cell{
			position: static;
		}

		.swiper-pagination-bullet-active{

			background: #fff;

		}

		.weui-tabbar__item.weui-bar__item--on .weui-tabbar__label{

			color:red;

		}

		.weui-tabbar__label{

			font-size: 16px;

		}

		.swiper-wrapper img{

			width: 100%;

			height: 100%;

		}

		.swiper-container-horizontal>.swiper-pagination-bullets, .swiper-pagination-custom, .swiper-pagination-fraction{

			bottom: 5px;

		}

    .footer{
      width: 100%;
      overflow: hidden;
      display: flex;
      height: 6rem;
      padding: 1rem 0;
      border-top: 0.05rem solid #ccc;
      position: fixed;
      bottom: 0;
      left: 0;
    }
    .footer a{
      float: left;
      display: block;
      /*width: 33%;*/
      color: #333;
      text-align: center;
      text-decoration: none;
    }
    .footer a img{
      display: inline-block;
      width:3rem;
      height:3rem;
    }
    .footer a p{
      text-align: center;
      font-size: 1.5rem;
      line-height: 3.8rem;
      margin:0;
    }

    .footer a:hover , .footer a:active{
      color: red;
    }

	</style>
</head>
<body>
	<div class="banner">
		
		<div class="swiper-container" id="swiper-container" style="height: 18rem;">

	      	<div class="swiper-wrapper" >
	      	{loop $banner $row}
					   <div class="swiper-slide"><img src="{$_W['attachurl']}{$row['img']}" alt=""></div>
				  {/loop}
				<!-- 
			    <div class="swiper-slide"><img src="https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=1656562954,584009141&fm=11&gp=0.jpg" alt=""></div>
			    <div class="swiper-slide"><img src="https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=1932490921,515120803&fm=11&gp=0.jpg" alt=""></div> -->
	      	</div>

	      	<div class="swiper-pagination"></div>

	    </div>	
	</div>

	<div class="scroll">
		<a class="all nav_avtive">全部</a>
		{loop $storemenu $row}
		<a class="nav"><input class="hide" type="hidden" value="{$row['id']}">{$row['title']}</a>
		{/loop}
	</div>

	<div class="weui-cells" id="store_list" style="margin-bottom: 8rem">
		<div class="noData">
			<img src="../addons/zh_yjm/template/mobile/images/noData.png">
			<p>暂无数据</p>
		</div>
		<!-- <div class="weui-cell list">
		  <div class="weui-cell__hd list_left"><img src="https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=1377916489,1349405445&fm=26&gp=0.jpg"></div>
		  <div class="weui-cell__bd list_title">
		    <p style="font-weight: bold;line-height: 3rem;height: 3rem ;">志汇科技美容店志汇科技美容店志汇科技美容店志汇科技美容店志汇科技美容店</p>
		    <p class="list_txt">美容店</	
		    <p style="height: 3rem ;">
		
		    </p>
		  </div>
		  <div class="weui-cell__ft list_right">600m</div>
		</div> -->

	</div>
		
	
	<!-- <iframe id="iframe1" name="iframe1" MARGINWIDTH=0 MARGINHEIGHT=0 HSPACE=0 VSPACE=0 FRAMEBORDER=0 SCROLLING=no src="../addons/zh_yjm/template/mobile/footer.html" height="auto" width="100%"></iframe> -->

  <div class="footer" id="footer" style="background-color:#fff;" >
    {loop $menus $row}
      <a {if $total==2}style="width:50%"{/if}  {if $total==3}style="width:33%"{/if}   {if $total==4}style="width:25%"{/if}   {if $total==5}style="width:20%"{/if} href="{$row['link']}">
        <img src="{$_W['attachurl']}{$row['img']}">
        <p>{$row['title']}</p>
      </a>
    {/loop}
  </div>

</body>


<script type="text/javascript" src='../addons/zh_yjm/template/mobile/js/jquery-2.1.4.js'></script>
<script src='../addons/zh_yjm/template/mobile/js/swiper.js'></script>
<script type="text/javascript" src='../addons/zh_yjm/template/mobile/js/index.js'></script>
<script type="text/javascript" src='../addons/zh_yjm/template/mobile/js/jquery-weui.js'></script>
<script type="text/javascript" src='../addons/zh_yjm/template/mobile/js/jquery-weui.min.js'></script>
<script type="text/javascript" src='../addons/zh_yjm/template/mobile/js/jquery-weui.min.js'></script>
<script type="text/javascript">
	  
	  var page=1
    if(sessionStorage.getItem("lat")){
      var lat=sessionStorage.getItem("lat")
      var lng=sessionStorage.getItem("lng")
    }else{
      var lat  //纬度
      var lng  //经度
    }


    $(".swiper-container").swiper({

      loop: true,

      autoplay: 3000,

    });


  $(function () {

    $(".noData").css("display","none")
      // $.ajax({
      //         type:"get",
      //         url:"{$_W['siteroot']}app/index.php?i={$_W['uniacid']}&c=entry&a=site&do=Storelista&m=zh_yjm",
      //         async:true,
      //         dataType:"json",
      //         data:{lat:30.532190864599663,lng:114.33727680414356},
      //         success:function(data){
      //         	// alert(data.data.length)
      //         	console.log(data)
      //            if(data.code==200){
      //            		for ( var i=0;i<data.data.length;i++) {
      //            			var str="<a href='{$_W['siteroot']}/app/index.php?i={$_W['uniacid']}&c=entry&do=store&m=zh_yjm&id="+data.data[i].id+"' class='weui-cell list'> <div class='weui-cell__hd list_left'><img src='{$_W['siteroot']}/attachment/"+data.data[i].img+"'></div> <div class='weui-cell__bd list_title'> <p style='font-weight: bold;line-height: 3rem;height: 3rem ;'>"+data.data[i].store+"</p> <p class='list_txt'>"+data.data[i].area+"</<p style='height: 3rem ;'> </p> </div> <div class='weui-cell__ft list_right'>"+data.data[i].juli+"m</div> </a> "
      //            			$("#store_list").append(str);
      //            		}
                 		
      //            }else if(data.code==501){
      //            		$(".noData").css("display","block")
      //            }
      //         },

      //         error : function(data) {

      //             alert(data.msg);

      //             return false

      //         }
      // })
      if(lat>0){
        showPositions() 
      }else{
        getLocation()
        showPosition()
      }      
  })

  $(".scroll a").click(function () {
  	$(".scroll a").removeClass('nav_avtive')
  	$(this).addClass('nav_avtive')
  })

	var x=document.getElementById("demo");//什么东西？
  function getLocation(){
      if (navigator.geolocation){
          navigator.geolocation.getCurrentPosition(showPosition);
      }else{
          alert('浏览器已拒绝获取位置信息')
      }
  }
  function showPosition(position){
      lat=position.coords.latitude;
      lng=position.coords.longitude;
      sessionStorage.setItem("lat", lat);
      sessionStorage.setItem("lng", lng);
     	// alert('纬度：'+lat+','+'经度:'+lng)
      $.ajax({
          type:"get",
          url:"{$_W['siteroot']}app/index.php?i={$_W['uniacid']}&c=entry&a=site&do=Storelista&m=zh_yjm",
          async:true,
          dataType:"json",
          data:{lat:lat,lng:lng,page:1},
          success:function(data){
            console.log(data)
             if(data.code==200){
                for ( var i=0;i<data.data.length;i++) {
                  var str="<a href='{$_W['siteroot']}/app/index.php?i={$_W['uniacid']}&c=entry&do=store&m=zh_yjm&id="+data.data[i].id+"' class='weui-cell list'> <div class='weui-cell__hd list_left'><img src='{$_W['siteroot']}/attachment/"+data.data[i].img+"'></div> <div class='weui-cell__bd list_title'> <p style='font-weight: bold;line-height: 3rem;height: 3rem ;'>"+data.data[i].store+"</p> <p class='list_txt'>"+data.data[i].area+"</<p style='height: 3rem ;'> </p> </div> <div class='weui-cell__ft list_right'>"+data.data[i].juli+"m</div> </a> "
                  $("#store_list").append(str);
                }
                
             }else if(data.code==501){
                $(".noData").css("display","block")
             }
          },

          error : function(data) {

              alert(data.msg);

              return false

          }
      })
  }
  function showPositions(){
      // alert('纬度：'+lat+','+'经度:'+lng)
      $.ajax({
          type:"get",
          url:"{$_W['siteroot']}app/index.php?i={$_W['uniacid']}&c=entry&a=site&do=Storelista&m=zh_yjm",
          async:true,
          dataType:"json",
          data:{lat:lat,lng:lng,page:1},
          success:function(data){
            console.log(data)
             if(data.code==200){
                for ( var i=0;i<data.data.length;i++) {
                  var str="<a href='{$_W['siteroot']}/app/index.php?i={$_W['uniacid']}&c=entry&do=store&m=zh_yjm&id="+data.data[i].id+"' class='weui-cell list'> <div class='weui-cell__hd list_left'><img src='{$_W['siteroot']}/attachment/"+data.data[i].img+"'></div> <div class='weui-cell__bd list_title'> <p style='font-weight: bold;line-height: 3rem;height: 3rem ;'>"+data.data[i].store+"</p> <p class='list_txt'>"+data.data[i].area+"</<p style='height: 3rem ;'> </p> </div> <div class='weui-cell__ft list_right'>"+data.data[i].juli+"m</div> </a> "
                  $("#store_list").append(str);
                }
                
             }else if(data.code==501){
                $(".noData").css("display","block")
             }
          },

          error : function(data) {

              alert(data.msg);

              return false

          }
      })
  }

  $(".all").click(function(){
    page=1
      // alert('第三个纬度：'+lat+','+'第三个经度'+lng)
	    $('#store_list').html("");
      $(".noData").css("display","none")

      $.ajax({
          type:"get",
          url:"{$_W['siteroot']}app/index.php?i={$_W['uniacid']}&c=entry&a=site&do=Storelista&m=zh_yjm",
          async:true,
          dataType:"json",
          data:{lat:lat,lng:lng,page:1},
          success:function(data){
          	console.log(data)
             if(data.code==200){
             		for ( var i=0;i<data.data.length;i++) {
             			var str="<a href='{$_W['siteroot']}/app/index.php?i={$_W['uniacid']}&c=entry&do=store&m=zh_yjm&id="+data.data[i].id+"' class='weui-cell list'> <div class='weui-cell__hd list_left'><img src='{$_W['siteroot']}/attachment/"+data.data[i].img+"'></div> <div class='weui-cell__bd list_title'> <p style='font-weight: bold;line-height: 3rem;height: 3rem ;'>"+data.data[i].store+"</p> <p class='list_txt'>"+data.data[i].area+"</<p style='height: 3rem ;'> </p> </div> <div class='weui-cell__ft list_right'>"+data.data[i].juli+"m</div> </a> "
             			$("#store_list").append(str);
             		}
             		
             }else if(data.code==501){
             		$(".noData").css("display","block")
             }
          },

          error : function(data) {

              alert(data.msg);

              return false

          }
      })
  });


  $(".nav").click(function () {
    page=1
  	console.log($(this).children("input").val())
  	var id=$(this).children("input").val()

  	$('#store_list').html("");
      $(".noData").css("display","none")

      $.ajax({
          type:"get",
          url:"{$_W['siteroot']}app/index.php?i={$_W['uniacid']}&c=entry&a=site&do=Storelist&m=zh_yjm",
          async:true,
          dataType:"json",
          data:{lat:lat,lng:lng,storetype_id:id,page:1},
          success:function(data){
          	console.log(data)
          	console.log(data.code)

             if(data.code==200){
             		for ( var i=0;i<data.data.length;i++) {
             			var str="<a href='{$_W['siteroot']}/app/index.php?i={$_W['uniacid']}&c=entry&do=store&m=zh_yjm&id="+data.data[i].id+"' class='weui-cell list'> <div class='weui-cell__hd list_left'><img src='{$_W['siteroot']}/attachment/"+data.data[i].img+"'></div> <div class='weui-cell__bd list_title'> <p style='font-weight: bold;line-height: 3rem;height: 3rem ;'>"+data.data[i].store+"</p> <p class='list_txt'>"+data.data[i].area+"</<p style='height: 3rem ;'> </p> </div> <div class='weui-cell__ft list_right'>"+data.data[i].juli+"m</div> </a> "
             			$("#store_list").append(str);
             		}
             		
             }else{
             	$(".noData").css("display","block")
             }
          },

          error : function(data) {

              alert(data.msg);

              return false

          }
      })
  })

  // $(document.body).pullToRefresh(function () {
  //   $("#store_list").html();
  //   $(".scroll a").removeClass('nav_avtive')
  //   $(".all").addClass('nav_avtive')
  //   $.ajax({
  //             type:"get",
  //             url:"{$_W['siteroot']}app/index.php?i={$_W['uniacid']}&c=entry&a=site&do=Storelista&m=zh_yjm",
  //             async:true,
  //             dataType:"json",
  //             data:{lat:lat,lng:lng,page:1},
  //             success:function(data){
  //               // alert(data.data.length)
  //               console.log(data)
  //                if(data.code==200){
  //                   for ( var i=0;i<data.data.length;i++) {
  //                     var str="<a href='{$_W['siteroot']}/app/index.php?i={$_W['uniacid']}&c=entry&do=store&m=zh_yjm&id="+data.data[i].id+"' class='weui-cell list'> <div class='weui-cell__hd list_left'><img src='{$_W['siteroot']}/attachment/"+data.data[i].img+"'></div> <div class='weui-cell__bd list_title'> <p style='font-weight: bold;line-height: 3rem;height: 3rem ;'>"+data.data[i].store+"</p> <p class='list_txt'>"+data.data[i].area+"</<p style='height: 3rem ;'> </p> </div> <div class='weui-cell__ft list_right'>"+data.data[i].juli+"m</div> </a> "
  //                     $("#store_list").append(str);
  //                   }
                    
  //                }else if(data.code==501){
  //                   $(".noData").css("display","block")
  //                }
  //             },

  //             error : function(data) {

  //                 alert(data.msg);

  //                 return false

  //             }
  //         })
  // });

  $(document.body).infinite().on("infinite", function () {
    // alert(page)
    page=page+1
    $("#store_list").html();
    if($(".all").hasClass('nav_avtive')){
        $.ajax({
            type:"get",
            url:"{$_W['siteroot']}app/index.php?i={$_W['uniacid']}&c=entry&a=site&do=Storelista&m=zh_yjm",
            async:true,
            dataType:"json",
            data:{lat:lat,lng:lng,page:page},
            success:function(data){
              // alert(data.data.length)
              console.log(data)
               if(data.code==200){
                  for ( var i=0;i<data.data.length;i++) {
                    var str="<a href='{$_W['siteroot']}/app/index.php?i={$_W['uniacid']}&c=entry&do=store&m=zh_yjm&id="+data.data[i].id+"' class='weui-cell list'> <div class='weui-cell__hd list_left'><img src='{$_W['siteroot']}/attachment/"+data.data[i].img+"'></div> <div class='weui-cell__bd list_title'> <p style='font-weight: bold;line-height: 3rem;height: 3rem ;'>"+data.data[i].store+"</p> <p class='list_txt'>"+data.data[i].area+"</<p style='height: 3rem ;'> </p> </div> <div class='weui-cell__ft list_right'>"+data.data[i].juli+"m</div> </a> "
                    $("#store_list").append(str);
                  }
                  
               }
            },

            error : function(data) {

                alert(data.msg);

                return false

            }
        })
    }else{
      var id=$('.nav_avtive').children("input").val()
      console.log(id)
      $.ajax({
            type:"get",
            url:"{$_W['siteroot']}app/index.php?i={$_W['uniacid']}&c=entry&a=site&do=Storelist&m=zh_yjm",
            async:true,
            dataType:"json",
            data:{lat:lat,lng:lng,storetype_id:id,page:page},
            success:function(data){
              console.log(data)
              console.log(data.code)

               if(data.code==200){
                  for ( var i=0;i<data.data.length;i++) {
                    var str="<a href='{$_W['siteroot']}/app/index.php?i={$_W['uniacid']}&c=entry&do=store&m=zh_yjm&id="+data.data[i].id+"' class='weui-cell list'> <div class='weui-cell__hd list_left'><img src='{$_W['siteroot']}/attachment/"+data.data[i].img+"'></div> <div class='weui-cell__bd list_title'> <p style='font-weight: bold;line-height: 3rem;height: 3rem ;'>"+data.data[i].store+"</p> <p class='list_txt'>"+data.data[i].area+"</<p style='height: 3rem ;'> </p> </div> <div class='weui-cell__ft list_right'>"+data.data[i].juli+"m</div> </a> "
                    $("#store_list").append(str);
                  }
                  
               }
            },

            error : function(data) {

                alert(data.msg);

                return false

            }
        })
    }
  });
</script>

</html>